﻿@using MoviesRoom.Areas.Administration.ViewModels

@{
    ViewBag.Title = "Films";
}

<div class="row-fluid">
    <div class="span12" id="films-container" style="margin-left:0px">
        <h2>Films</h2>
        @(Html.Kendo()
              .Grid<GridFilmViewModel>()
              .Name("grid-films")
              .Columns(columns =>
              {
                  columns.Bound(model => model.Title);
                  columns.Bound(model => model.PricePerTicket);
                  columns.Bound(model => model.AvailableTickets);
                  columns.Bound(model => model.StartDate);
                  columns.Bound(model => model.Description);
                  columns.Bound(model => model.CategoryName);
                  columns.Command(command =>
                  {
                      command.Edit();
                      command.Destroy();
                  }).Title("Action");
              })
              .ToolBar(tool =>
              {
                  tool.Create();
              })
              .Pageable()
              .Sortable()
              .Filterable()
              .Resizable(resize =>
              {
                  resize.Columns(true);
              })
              .Editable(edit =>
              {
                  edit.Mode(GridEditMode.PopUp);
                  edit.TemplateName("GridEditor");
              })

              .DataSource(data =>
              {
                  data.Ajax()
                      .Model(m => m.Id(f => f.Id))
                      .PageSize(5)
                      .ServerOperation(true)
                      .Read("GetAllFilms", "Film")
                      .Update("UpdateFilm", "Film")
                      .Create("CreateFilm", "Film")
                      .Destroy("DeleteFilm", "Film");
              })
        )
    </div>
</div>

@section Kendo {
    @Styles.Render("~/Content/Kendo/css")
    @Scripts.Render("~/bundles/kendo");
}
